<?
include '../include/common.php';
$name = null;
$width = null;
$height = null;
if (isset($_GET['name'])) {
	$name = get('name');
}
if (isset($_GET['width'])) {
	$width = get('width');
}
if (isset($_GET['height'])) {
	$height = get('height');
}
$name = '../' . $name;
//header('Content-type: image/png');
list($width_orig, $height_orig, $type) = getimagesize($name);
if ($width && ($width_orig < $height_orig)) {
    $width = ($height / $height_orig) * $width_orig;
} else {
    $height = ($width / $width_orig) * $height_orig;
}
$image_p = imagecreatetruecolor($width, $height);
$image = null;
switch ($type) {
	case 1:
		$image = imagecreatefromgif($name);
	break;
	case 2:
		$image = imagecreatefromjpeg($name);
	break;
	case 3:
		$image = imagecreatefrompng($name);
	break;
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, null, 100);
?> 